package com.example.tms.mapper;

import com.example.tms.bean.MoneyInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

/**
 * 现金报账
 */
public interface MoneyMapper extends JpaRepository<MoneyInfo, String>, JpaSpecificationExecutor<MoneyInfo> {

    //查询报账信息（报账id）
    @Query(value = "select * from money_info where xjbzid = ?1 and sfcz = true", nativeQuery = true)
    MoneyInfo findByXjbzid(String xjbzid);

    //删除报账信息（假删除 报账id）
    @Query(value = "update money_info set sfcz = false where xjbzid = ?1", nativeQuery = true)
    @Modifying
    @Transactional
    void DeleteByXjbzid(String xjbzid);
}